import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入自己的vue
import Login from '../views/login/Login.vue'
import Layout from '../views/layout/Layout.vue'

Vue.use(VueRouter)

const routes = [
  // 登入页路由
  {
    path: '/login',
    component: Login
  },
  // 后台首页路由
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        // 懒加载......
        component: () => import('../views/home/Home.vue')
      }
    ]
  },
  // 订单管理路由
  {
    path: '/order',
    component: Layout,
    redirect: '/order-list',
    meta: {
      path: '/order',
      text: '订单管理'
    },
    children: [
      {
        path: '/order-list',
        component: () => import('../views/order/OrderList.vue')
      }
    ]

  },
  // 商品管理路由
  {
    path: '/goods',
    component: Layout,
    redirect: '/goods-add',
    meta: {
      path: '/goods',
      text: '商品添加'
    },
    children: [
      {
        // 商品添加路由
        path: '/goods-add',
        meta: {
          path: '/goods-add',
          text: '商品添加'
        },
        component: () => import('../views/goods/GoodsAdd.vue')
      },
      {
        // 商品列表路由
        path: '/goods-list',
        meta: {
          path: '/goods-list',
          text: '商品列表'
        },
        component: () => import('../views/goods/GoodsList.vue')
      },
      {
        // 商品分类路由
        path: '/goods-type',
        meta: {
          path: '/goods-add',
          text: '商品分类'
        },
        component: () => import('../views/goods/GoodsType.vue')
      }
    ]
  },
  // 店铺管理路由
  {
    path: '/shop',
    component: Layout,
    redirect: '/shop-list',
    meta: {
      path: '/shop',
      text: '店铺管理'
    },
    children: [
      {
        path: '/shop-list',
        meta: {
          path: '/shop-list',
          text: '店铺管理'
        },
        component: () => import('../views/shop/ShopList.vue')
      }
    ]
  },
  // 账号管理路由
  {
    path: '/account',
    component: Layout,
    redirect: '/account-add',
    meta: {
      path: '/account',
      text: '账号添加',
    },
    children: [
      {
        // 账号添加路由
        path: '/account-add',
        meta: {
          path: '/account-add',
          text: '账号添加',
        },
        component: () => import('../views/account/AccountAdd.vue')
      },
      {
        // 账号列表
        path: '/account-list',
        meta: {
          path: '/account-list',
          text: '账号列表',
        },
        component: () => import('../views/account/AccountList.vue')
      },
      {
        // 修改账号路由
        path: '/account-edi',
        meta: {
          path: '/account-edi',
          text: '修改密码',
        },
        component: () => import('../views/account/AccountEdit.vue')
      },
      {
        // 个人中心路由
        path: '/account-center',
        meta: {
          path: '/account-center',
          text: '个人中心',
        },
        component: () => import('../views/account/AccountCenter.vue')
      },
    ]
  },
  // 销售统计
  {
    path: '/statistics',
    component: Layout,
    redirect: '/goods-statistics',
    meta: {
      path: '/statistics',
      text: '销售统计'
    },
    children: [
      {
        // 商品添加路由
        path: '/goods-statistics',
        meta: {
          path: '/goods-statistics',
          text: ' 商品统计'
        },
        component: () => import('../views/statistics/GoodsStatistics.vue')
      },
      {
        // 订单统计路由
        path: '/order-statistics',
        meta: {
          path: '/order-statistics',
          text: '订单统计'
        },
        component: () => import('../views/statistics/OrderStatistics.vue')
      },
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
